#pragma once
#include<iostream>
#include<pthread.h>
#include<semaphore.h>
namespace SemModule{
    class Sem{
        public:
            Sem(unsigned int value=1){
                sem_init(&sem_,0,value);
            }
            ~Sem(){
                sem_destroy(&sem_);
            }
            void P(){
                sem_wait(&sem_);//原子操作
            }
            void V(){
                sem_post(&sem_);
            }
        private:
            sem_t sem_;
    };
}